<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page isELIgnored="false"%>
<%@ include file="../common/taglibs.jsp"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <title>SN释放</title>
    <link rel="icon" href="favicon.ico" type="image/x-icon"/>
    <!-- 当前页面样式 -->
    <link rel="stylesheet" href="<s:url value="/css/common.css"/>"/>
    <!-- 当前页面样式 END -->
	<script type="text/javascript" src="<c:url value="/js/jquery-1.3.2.js" />"></script>
	<script type="text/javascript">
	$(document).ready(function() {
		$("#szPower").click(
				function() {
					var params = {};
					params.data = new Array();
					var dd = $("input[name=data]:checked");
					$(dd).each(function(i,val){
						var info = {};
						info.mid = $(val).attr("data-mid");					
						info.tid = $(val).attr("data-tid");					
						info.did = $(val).attr("date-did");
						params.data.push(info);
					});	
					  console.warn(JSON.stringify(params));
					if(dd.length == 0){
						alert("请选择商户");
						return false;
						
					}if(dd.length > 16){
						alert("1次最多只能释放15个！！！");
						return false;
					}
						else{
						//
						$("#check").attr("disabled","disabled");
						$.ajax({
							url:"<%=basePath%>/snRelease/SnRelease.ct",
							type:"post",
                         	data:{"snList.DeviceCd":JSON.stringify(params)}, 
// 							data:{"snList":JSON.stringify(params)},
							dataType:"json",
							success:function(result){
								alert(result.msg);
								if(result.boo){
									window.location.href="<%=basePath%>/snRelease/querySnRelease.ct";
								}
								
							},error:function(){
								alert("未知错误！");
							}
						});
					}
					
				}		
			);
			
		})
	

	function queryForm(){
		$("#queryUserForm").attr("action","<%=basePath%>/snRelease/querySnRelease.ct");
		$("#queryUserForm").submit();
		
	}

	


	function queryForm(){
		$("#queryUserForm").attr("action","<%=basePath%>/snRelease/querySnRelease.ct");
		$("#queryUserForm").submit();
		
	}
</script>
</head>
<body>
<s:form id="queryUserForm" action="" method="post" theme="simple">
<table class="tb">
    <tbody>
        <tr class="tb-line">
            <td class="tb-td" colspan="4"><div class="tb-h2">POS收单运营管理平台</div></td>
        </tr>

        <tr class="tb-line">
            <td class="tb-td" colspan="4"><div class="tb-h3">SN释放</div></td>
        </tr>
 
        <tr class="tb-line">
            <td align="right" class="tb-td">
                <div class="tb-h4">商户号：</div>
            </td>
            <td class="tb-td">
                <label class="tb-input-normal">
                	<s:textfield  id="merno" name="searchCondition.mchtCd" />
               	</label>
            </td>
            <td align="right" class="tb-td">
                <div class="tb-h4">商户名称：</div>
            </td>
            <td class="tb-td">
                <label class="tb-input-normal">
                	<s:textfield  id="merno" name="searchCondition.nameBusi" />
               	</label>
            </td>
            </tr>
             <tr class="tb-line">
             <td align="right" class="tb-td">
                <div class="tb-h4">终端号：</div>
            </td>
            <td class="tb-td">
                <label class="tb-input-normal">
                	<s:textfield  name="searchCondition.termId" maxlength="20"/>
                </label>
            </td>
            <td align="right" class="tb-td">
                <div class="tb-h4">终端设备序列号：</div>
            </td>
            <td class="tb-td">
                <label class="tb-input-normal">
                	<s:textfield  name="searchCondition.deviceCd" maxlength="25"/>
                </label>
            </td>
           
        </tr>
        <tr>
			<td colspan="7" align="center"><span style="color: red"><s:actionerror /></span>
							<span style="color: red;"><s:actionmessage /></span > <span style="color: red;"><s:fielderror
									cssClass="fieldError" /></span>
							<span id="otherError"></span>
						</td>
					</tr>

        <tr class="tb-line">
            <td class="tb-td line-submit" align="right" colspan="4">
                <label class="tb-input-submit">
                    <input type="button" value="查 询"  onclick='queryForm()'/>
                </label>
                <label class="tb-input-submit">
                    <input type="reset" value="取 消"/>
                </label>
                <label class="tb-input-submit">
                    <input id="szPower" type="button"  value="释 放" />
                </label>
            </td>
        </tr>
        <s:if test="#request.searchRsList != null && #request.searchRsList.size>0 ">     
			<tr class="tb-line">
				<td class="tb-td paging"  align="left" colspan="4"> 
					 	<page:pageCount max_pages="11" totalPage="${requestScope.totalPage}"
						currentPage="${requestScope.currentPage}"
						action="${rootPath}/snRelease/querySnRelease.ct?currentPage=" />

				</td>
			</tr>
		</s:if>
    </tbody>
</table>
</s:form>
<div class="big-tb">
    <table class="tb" style="width: 120%;">
        <thead>
            <tr class="tb-line">
                <th class="tb-th" colspan="9">SN查询信息列表</th>
            </tr>
            <tr class="tb-line bg-gray">
                <th class="tb-th">选择</th>
                <th class="tb-th">商户号</th>
				<th class="tb-th">商户名称</th>
				<th class="tb-th">所属代理商</th>
				<th class="tb-th">所属机构</th>			
				<th class="tb-th">终端类型</th>
				<th class="tb-th">终端编号</th>
				<th class="tb-th">终端设备序列号</th>
				<th class="tb-th">安装位置</th>
            </tr>
        </thead>
        <tbody>
			<s:iterator value="#request.searchRsList" status="stat" id="sn">
				<tr class="tb-line" >
					<td align="center" class="tb-td">
				<input name="data" 
				value ="" data-mid="<s:property value='#sn.mchtCd'/>"
				 data-tid ="<s:property value='#sn.termId'/>" 
				 date-did="<s:property value='#sn.DeviceCd'/>"  
				    type="checkbox"> 
			        </td>
					<td class="tb-td"><s:property value="#sn.mchtCd"/></td>
					<td class="tb-td"><s:property value="#sn.nameBusi"/></td>
			        <td class="tb-td"><s:property value="#sn.agentName"/></td>
			        <td class="tb-td"><s:property value="#sn.oneAgent"/> </td>
			         <td class="tb-td"><s:property value="#sn.TermTp"/> </td>
			         <td class="tb-td"><s:property value="#sn.termId"/> </td> 
                     <td class="tb-td"><s:property value="#sn.DeviceCd"/> </td>  
			        <td class="tb-td"><s:property value="#sn.Installlocation"/> </td>  
			      </tr>
			</s:iterator>	
        </tbody>
    </table>
   
</div>
 <s:if test="#request.info_request !=null">
	<script language="javascript">
	    alert("${request.info_request}");
	    </script>
	</s:if>	
</body>
</html>